package com.lm.orika.config;

import com.lm.orika.bean.MapperFactoryBean;
import ma.glasnost.orika.MapperFacade;
import ma.glasnost.orika.MapperFactory;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OrikaConfig {
    @Bean
    @ConditionalOnMissingBean(MapperFactoryBean.class)
    public MapperFactoryBean loadFactory() {
        return new MapperFactoryBean();
    }

    @Bean
    @ConditionalOnMissingBean(MapperFacade.class)
    public MapperFacade loadMapperFacade(MapperFactory factory) {
        return factory.getMapperFacade();
    }
}
